const jwt = require("jsonwebtoken");
module.exports = (req, res, next) => {
  //校验token
  let token = req.get('token')
  if (!token) {
    return  res.json(
      {
        code:'0000',
        msg:'失败_没有token',
        data:null
      })
  }

  jwt.verify(token,'wab',(err,data) => {
    if (err){
      return res.json({
        code:'2003',
        msg:'token错误',
        data:null
      })
    }
  })
  //token校验成功
  next()
}